package com.thalesgroup.preferenceFramework.models.LCPnet.fragments;

import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.junit.Before;
import org.junit.Test;

import com.thalesgroup.preferenceFramework.models.LCPnet.CLPT;
import com.thalesgroup.preferenceFramework.models.LCPnet.CLPTLine;
import com.thalesgroup.preferenceFramework.models.LCPnet.Coordinate;
import com.thalesgroup.preferenceFramework.models.LCPnet.LCPnet;
import com.thalesgroup.preferenceFramework.models.LCPnet.LNode;
import com.thalesgroup.preferenceFramework.models.LCPnet.LNodeValueUtility;
import com.thalesgroup.preferenceFramework.models.LCPnet.LinguisticSubset;
import com.thalesgroup.preferenceFramework.models.LCPnet.exceptions.LCPnetCombinationException;
import com.thalesgroup.preferenceFramework.models.LCPnet.exceptions.LCPnetEvaluationException;
import com.thalesgroup.preferenceFramework.models.LCPnet.fragments.impl.LCPnetFragmentImpl;
import com.thalesgroup.preferenceFramework.models.LCPnet.impl.LCPnetImpl;

import junit.framework.TestCase;

public class LCPnetFragmentTests  extends TestCase {
	
	@Test
	public void test() throws LCPnetCombinationException, LCPnetEvaluationException {
		LCPnet computed_preferences = LCPnetFragmentImpl.getCombinedLCPnet("../allPlugins_workspace/preferenceTest/modificator.fragments");
		assertNotNull(computed_preferences);
		
		LCPnet preferences = LCPnetImpl.load("../allPlugins_workspace/preferenceTest/monitoring_preferences_modified.lcpnet");
		assertNotNull(preferences);
		
		EList<String> nodeNames = new BasicEList<String>();
		nodeNames.add("security");
		nodeNames.add("bandwidth");
		nodeNames.add("zoom");
		
		EList<Double> nodeValues = new BasicEList<Double>();
		nodeValues.add(0.4);
		nodeValues.add(1.0);
		nodeValues.add(0.51);
		
		double computed_utility = computed_preferences.getUtility(nodeNames, nodeValues);
		System.out.println("computed_utility = " + computed_utility);
		
		double utility = preferences.getUtility(nodeNames, nodeValues);
		System.out.println("utility = " + utility);
		
		assertEquals(computed_utility, utility);

	}
}
